home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Text / print / HPDJ900Src.lha / transfer.c < prev   
C/C++ Source or Header  |  2004-05-21  |  4KB  |  105 lines

  1. /*
  2.  * Transfer routine for HP_Deskjet_900C
  3.  */
  4.  
  5. #include "global.h"
  6.  
  7. #define NUMCOLORCMD 7
  8.  
  9. void Transfer(struct PrtInfo *PInfo, ULONG y, UBYTE *colors[], UWORD RowSize, UWORD NumColorBuf)
  10. {
  11.         extern struct PrinterData *PD;
  12.         extern struct PrinterExtendedData *PED;
  13.  
  14.         static UBYTE bit_table[] = {128, 64, 32, 16, 8, 4, 2, 1};
  15.         UBYTE *dmatrix, Black, dvalue, threshold;
  16.         union colorEntry *ColorInt;
  17.         UWORD x, width, sx, *sxptr;
  18.         UBYTE Yellow, Magenta, Cyan, *bptr, *yptr, *mptr, *cptr;
  19.  
  20.         /* pre-compute */
  21.         /* printer non-specific, MUST DO FOR EVERY PRINTER */
  22.         x = PInfo->pi_xpos; /* get starting x position */
  23.         ColorInt = PInfo->pi_ColorInt; /* get ptr to color intensities */
  24.         sxptr = PInfo->pi_ScaleX;
  25.         width = PInfo->pi_width; /* get # of source pixels */
  26.         bptr = colors[0]; /* Assign color pointers */
  27.         cptr = colors[1];
  28.         mptr = colors[2];
  29.         yptr = colors[3];
  30.  
  31.         /* pre-compute threshold; are we thresholding? */
  32.  
  33.         if (threshold = PInfo->pi_threshold) { /* thresholding */
  34.                 dvalue = threshold ^ 15; /* yes, so pre-compute dither value */
  35.                 do { /* for all source pixels */
  36.                         /* pre-compute intensity value for Black */
  37.                         Black = ColorInt->colorByte[PCMBLACK];
  38.                         ColorInt++; /* bump ptr for next time */
  39.  
  40.                         sx = *sxptr++;
  41.  
  42.                         /* dither and render pixel */
  43.                         do { /* use this pixel 'sx' times */
  44.                                 /* if we should render Black */
  45.                                 if (Black > dvalue) {
  46.                                         /* set bit */
  47.                                         *(bptr + (x >> 3)) |= bit_table[x & 7];
  48.                                 }
  49.                                 ++x; /* done 1 more printer pixel */
  50.                         } while (--sx);
  51.                 } while (--width);
  52.         }
  53.         else { /* not thresholding, pre-compute ptr to dither matrix */
  54.              dmatrix = PInfo->pi_dmatrix + ((y & 3) << 2);
  55.              if (PD->pd_Preferences.PrintShade == SHADE_GREYSCALE)
  56.              {
  57.                 do { /* for all source pixels */
  58.                         /* pre-compute intensity value for Black */
  59.                         Black = ColorInt->colorByte[PCMBLACK];
  60.                         ColorInt++; /* bump ptr for next time */
  61.  
  62.                         sx = *sxptr++;
  63.  
  64.                         /* dither and render pixel */
  65.                         do { /* use this pixel 'sx' times */
  66.                                 /* if we should render Black */
  67.                                 if (Black > dmatrix[x & 3]) {
  68.                                         /* set bit */
  69.                                         *(bptr + (x >> 3)) |= bit_table[x & 7];
  70.                                 }
  71.                                 ++x; /* done 1 more printer pixel */
  72.                         } while (--sx);
  73.                 } while (--width);
  74.              }
  75.              else
  76.              { /* color */
  77.                do {
  78.                     Black = ColorInt->colorByte[PCMBLACK];
  79.                     Yellow = ColorInt->colorByte[PCMYELLOW];
  80.                     Magenta = ColorInt->colorByte[PCMMAGENTA];
  81.                     Cyan = ColorInt->colorByte[PCMCYAN];
  82.                     ColorInt++;
  83.  
  84.                     sx = *sxptr++;
  85.  
  86.                     do {
  87.                          dvalue = dmatrix[x & 3];
  88.                          if (Black > dvalue)
  89.                               *(bptr + (x >> 3)) |= bit_table[x & 7];
  90.                          else
  91.                          {
  92.                               if (Yellow > dvalue)
  93.                                    *(yptr + (x >> 3)) |= bit_table[x & 7];
  94.                               if (Magenta > dvalue)
  95.                                    *(mptr + (x >> 3)) |= bit_table[x & 7];
  96.                                if (Cyan > dvalue)
  97.                                   *(cptr + (x >> 3)) |= bit_table[x & 7];
  98.                          }
  99.                         ++x;
  100.                     } while (--sx);
  101.                } while (--width);
  102.              } /* endif */
  103.          } /* endif */
  104. } /* end main */
  105.